package com.example.design.controller;

import com.example.design.bo.PaymentBody;
import com.example.design.factory.PaymentStrategyHandler;
import com.example.design.service.StrategyRunner;
import com.example.design.utils.SFTPUtil;
import com.jcraft.jsch.JSchException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:
 * @Author Hong Qiang
 * @Date 2023/3/10 16:24
 * @Version 1.0
 */
@RestController
@RequestMapping(value = "/designPatterns")
public class DesignPatternController {

    @Autowired
    private StrategyRunner strategyRunner;

    @RequestMapping("/test")
    public void test() throws JSchException {
        SFTPUtil.getChannel("112.126.81.206",22,"root",6000);
    }

    @GetMapping(value = "/algorithm")
    public void algorithm(@RequestParam("strategy") String strategy) {
        strategyRunner.execute(strategy);
    }

    @PostMapping(value = "/pay")
    public Boolean pay(PaymentBody paymentBody){
        return PaymentStrategyHandler.pay(paymentBody);
    }
}
